home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #2 / Monster Media No. 2 (Monster Media)(1994).ISO / prog_bas / mquery.zip / MSORT.FRM < prev    next >
Text File  |  1994-05-24  |  3KB  |  131 lines

  1. VERSION 2.00
  2. Begin Form fSort 
  3.    BackColor       =   &H00C0C0C0&
  4.    BorderStyle     =   1  'Fixed Single
  5.    Caption         =   "Sort Records"
  6.    ClientHeight    =   2370
  7.    ClientLeft      =   3090
  8.    ClientTop       =   3120
  9.    ClientWidth     =   5070
  10.    ControlBox      =   0   'False
  11.    Height          =   2835
  12.    Left            =   3000
  13.    LinkTopic       =   "Form1"
  14.    MaxButton       =   0   'False
  15.    MinButton       =   0   'False
  16.    ScaleHeight     =   2412
  17.    ScaleMode       =   0  'User
  18.    ScaleWidth      =   5160
  19.    Top             =   2745
  20.    Width           =   5250
  21.    Begin ListBox cFieldList 
  22.       BackColor       =   &H00FFFFFF&
  23.       Height          =   1395
  24.       Left            =   240
  25.       TabIndex        =   1
  26.       Tag             =   " OL"
  27.       Top             =   360
  28.       Width           =   1695
  29.    End
  30.    Begin CommandButton OkayButton 
  31.       Caption         =   "&OK"
  32.       Default         =   -1  'True
  33.       Enabled         =   0   'False
  34.       Height          =   372
  35.       Left            =   2340
  36.       TabIndex        =   3
  37.       Top             =   420
  38.       Width           =   1691
  39.    End
  40.    Begin CommandButton CancelButton 
  41.       Cancel          =   -1  'True
  42.       Caption         =   "&Cancel"
  43.       Height          =   372
  44.       Left            =   2340
  45.       TabIndex        =   0
  46.       Top             =   1320
  47.       Width           =   1691
  48.    End
  49.    Begin Label FieldListLabel 
  50.       BackColor       =   &H00C0C0C0&
  51.       Caption         =   "Fields:"
  52.       Height          =   192
  53.       Left            =   240
  54.       TabIndex        =   2
  55.       Top             =   120
  56.       Width           =   1092
  57.    End
  58. End
  59. Option Explicit
  60. Dim FNotFound As Integer
  61.  
  62. Sub CancelButton_Click ()
  63.   Hide
  64.   'set the flag for the dynaset/dynagrid form
  65.   gfFindFailed = True
  66. End Sub
  67.  
  68. Sub cFieldList_Click ()
  69.   If cFieldList <> "" Then
  70.     OkayButton.Enabled = True
  71.   Else
  72.     OkayButton.Enabled = False
  73.   End If
  74. End Sub
  75.  
  76. Sub Form_Load ()
  77.    Me.Left = (screen.Width - Me.Width) / 2
  78.    Me.Top = (screen.Height - Me.Height) / 2
  79.  
  80. End Sub
  81.  
  82. Sub Form_Paint ()
  83.   Outlines Me
  84. End Sub
  85.  
  86. Sub OkayButton_Click ()
  87.    Dim i As Integer
  88.    Dim k As Integer
  89.    Dim stripedSort As String
  90.    On Error GoTo FindErr
  91.  
  92.   
  93.    FNotFound = False
  94.    SetHourGlass Me
  95.     gSortStr = cFieldList
  96.     stripedSort = gSortStr ' needed for compare later
  97.  
  98.     gSortStr = "[" + gSortStr + "]"
  99.       
  100.  
  101. ' see if this was not a stored query..if not add to SQL statement for save
  102.  If Not gStoredFlag Then
  103.     i = InStr(1, UCase(gstDynaString), "ORDER BY") 'see if a where exists
  104.         If i = 0 Then
  105.             gstDynaString = Trim(gstDynaString) & " Order By " & gTblname & "." & gSortStr
  106.         Else
  107.             k = InStr(i + 8, UCase(gstDynaString), UCase(stripedSort))' is this sort already used?
  108.             If k = 0 Then
  109.                 gstDynaString = Trim(gstDynaString) & "," & gTblname & "." & gSortStr
  110.             End If
  111.         End If
  112.  End If
  113.    
  114.    Hide
  115.    GoTo FindEnd
  116.  
  117. FindErr:
  118.    If Err <> EOF_ERR Then
  119.      ShowError
  120.      Resume FindEnd
  121.    Else
  122.      FNotFound = True
  123.      Resume Next
  124.    End If
  125.  
  126. FindEnd:
  127.    ResetMouse Me
  128.  
  129. End Sub
  130.  
  131.